package com.ruoyi.fitsculpt.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fitsculpt.domain.EasyfitExercisePlanDetails;
import com.ruoyi.fitsculpt.service.IEasyfitExercisePlanDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 运动计划详情Controller
 *
 * @author metaee
 * @date 2025-02-27
 */
@Api(tags = "运动计划详情管理")
@RestController
@RequestMapping("/fitsculpt/details")
public class EasyfitExercisePlanDetailsController extends BaseController {
    @Autowired
    private IEasyfitExercisePlanDetailsService easyfitExercisePlanDetailsService;

    /**
     * 查询运动计划详情列表
     */
    @ApiOperation("查询运动计划详情列表")
    @GetMapping("/list")
    public TableDataInfo list(EasyfitExercisePlanDetails easyfitExercisePlanDetails) {
        startPage();
        List<EasyfitExercisePlanDetails> list = easyfitExercisePlanDetailsService.selectEasyfitExercisePlanDetailsList(easyfitExercisePlanDetails);
        return getDataTable(list);
    }

    /**
     * 导出运动计划详情列表
     */
    @ApiOperation("导出运动计划详情列表")
    @Log(title = "运动计划详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EasyfitExercisePlanDetails easyfitExercisePlanDetails) {
        List<EasyfitExercisePlanDetails> list = easyfitExercisePlanDetailsService.selectEasyfitExercisePlanDetailsList(easyfitExercisePlanDetails);
        ExcelUtil<EasyfitExercisePlanDetails> util = new ExcelUtil<EasyfitExercisePlanDetails>(EasyfitExercisePlanDetails.class);
        util.exportExcel(response, list, "运动计划详情数据");
    }

    /**
     * 获取运动计划详情详细信息
     */
    @ApiOperation("获取运动计划详情详细信息")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@ApiParam(value = "运动计划详情ID", required = true) @PathVariable("detailId") Long detailId) {
        return success(easyfitExercisePlanDetailsService.selectEasyfitExercisePlanDetailsByDetailId(detailId));
    }

    /**
     * 新增运动计划详情
     */
    @ApiOperation("新增运动计划详情")
    @Log(title = "运动计划详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EasyfitExercisePlanDetails easyfitExercisePlanDetails) {
        return toAjax(easyfitExercisePlanDetailsService.insertEasyfitExercisePlanDetails(easyfitExercisePlanDetails));
    }

    /**
     * 修改运动计划详情
     */
    @ApiOperation("修改运动计划详情")
    @Log(title = "运动计划详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EasyfitExercisePlanDetails easyfitExercisePlanDetails) {
        return toAjax(easyfitExercisePlanDetailsService.updateEasyfitExercisePlanDetails(easyfitExercisePlanDetails));
    }

    /**
     * 删除运动计划详情
     */
    @ApiOperation("删除运动计划详情")
    @Log(title = "运动计划详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{detailIds}")
    public AjaxResult remove(@ApiParam(value = "运动计划详情ID数组", required = true) @PathVariable Long[] detailIds) {
        return toAjax(easyfitExercisePlanDetailsService.deleteEasyfitExercisePlanDetailsByDetailIds(detailIds));
    }
}
